<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>商品编辑</title>
<hdjs/>
<script>
    //传商品id给异步处理
    var goods_gid="{$field.gid}";
</script>
<js file="__CONTROLLER_VIEW__/Js/addEdit.js"/>

<!--编辑时 商品有商品类型时，自动获得商品属性-->
<if value="$field.goods_type">
    <script>
        $(function(){
            $("[name='goods_type']").val("{$field.goods_type}").change();
        })
    </script>
</if>
</head>
<body>
<form action="" method="post" enctype='multipart/form-data'>
<input type="hidden" name="gid" value="{$field.gid}">
	<div class="tab">
		<ul class="tab_menu">
			<li lab='base'>
			<a >基本选项</a>	
			</li>
			<li lab='other' class="action">
			<a >其他</a>	
			</li>
			<li lab='content'>
			<a >详情</a>	
			</li>
			<li lab='image'>
			<a >图片列表</a>	
			</li>
			<li lab='attribute'>
			<a >商品属性</a>	
			</li>
		</ul>
		<div class="tab_content hd-form">
			<div id="base">
				<table class="table1">
					<tr>
						<th class="W100">商品名称</th>
						<td>
							<input type="text" name="goods_name" class="w200" value="{$field.goods_name}">
						</td>
					</tr>
					<tr>
						<th>栏目</th>
						<td>
							<select name="category_cid">
								<option value="0">==请选择栏目==</option>
								<list from='$category', name='$c'>
								<option value="{$c.cid}"  <if value="$field.category_cid == $c.cid">selected=""</if>>{$c._name} </option>
								</list>
							</select>
						</td>
					</tr>
					<tr>
						<th>商品货号</th>
						<td>
						<input type="text" name="goods_sn" class="w200" value="{$field.goods_sn}">	
						</td>
					</tr>
					<tr>
						<th>属性</th>
						<td>
							<label>
								<input type="checkbox" name="is_hot" value="1" <if value="$field.is_hot ==1">checked=""</if>>
								热门
							</label>
							<label>
								<input type="checkbox" name="is_new" value="1" <if value="$field.is_new ==1">checked=""</if>>
								新品
							</label>
							<label>
								<input type="checkbox" name="is_best" value="1" <if value="$field.is_best ==1">checked=""</if>>
								精品
							</label>	
						</td>
							
					</tr>
					<tr>
						<th>图片</th>
						<td>
							<input type="file" name="original_img" >
							<if value="$field.original_img">
								<img src="__ROOT__/{$field.original_img}" alt="商品首页图片" width="100">
							</if>
						</td>
					</tr>
					<tr>
						<th>是否上架</th>
						<td>
							<label >
								<input type="radio" name="is_on_sale" value="0" <if value="$field.is_on_sale ==0">checked=""</if>>下架
							</label>
							<label >
								<input type="radio" name="is_on_sale" value="1" <if value="$field.is_on_sale ==1">checked=""</if>>上架
							</label>
						</td>
					</tr>
					<tr>
						<th>市场价</th>
						<td>
						<input type="text" name="market_price" class='w200' value="{$field.market_price}" /></td>
					</tr>
					<tr>
            			<th>商城价格</th>
           				<td>
            				<input type="text" name="goods_price" class='w200' value="{$field.goods_price}"/>
            			</td>
        		  </tr>
				</table>
			</div>
			<div id="other">
				<table class="table1">
					<tr>
						<th class="w100">单位</th>
						<td>						
							<select name="goods_Company">
				               <option value="件" <if value="$field.goods_Company ==件">selected=""</if>>件</option>
				               <option value="双" <if value="$field.goods_Company ==双">selected=""</if>>双</option> 
             				 </select>
						</td>
					</tr>
					<tr>
						<th class="w100">上架时间</th>
						<td><!-- 把时间戳时间转为现在时间 -->
							<input type="text" readonly="readonly" id="sale_time" name="sale_time" value="{$field.sale_time|date:'Y/m/d H:i:s',@@}" class="w150"/>
					<script>
						$('#sale_time').calendar({format: 'yyyy/MM/dd HH:mm:ss'});
					 </script>
						</td>
					</tr>
					<tr>
						<th>品牌</th>
						<td>
							<select name="brand_bid" class='w100'>
							<list from='$brand' name='$b'>
								<option value="{$b.bid}" <if value="$field.brand_bid == $b.bid">selected=""</if>>{$b.brand_name}</option>
								</list>
							</select>
						</td>
					</tr>
					<tr>
						<th>商品数量</th>
						<td><input type="text" name="goods_number" class="w200" value="{$field.goods_number}"></td>
					</tr>
					<tr>
						<th>查看</th>
						<td>
							<input type="text" name="goods_click" class="w200" value="{$field.goods_click}">次
						</td>
					</tr>
				</table>
			</div>
			<div id="content">
				<table class="table1">
					<tr>
						<th class="w100">关键字</th>
						<td>
							<input type="text" name="goods_key" class="w200" value="{$goods_data.goods_key}">
						</td>
					</tr>
					<tr>
						<th>描述</th>
						<td>
							<textarea name="goods_desc" class="w200 h100">{$goods_data.goods_desc}</textarea>
						</td>
					</tr>
					<tr>
						<th>详情</th>
						<td>
						<!-- 编辑器里面的用content不用value -->
							<ueditor name='goods_body' content="{$goods_data.goods_body}"/>
						</td>
					</tr>
				</table>
			</div>
			<div id='image'>
	        	<table class='table1'>
	        		<tr>
	        			<th class='w100'>图片列表</th>
	        			<td>
			                <div class="gallery">
		                    <ul>
		                        <list from="$gallery" name="$g">
	                            <li style="float:left;margin:10px;">
	                                <img src="__ROOT__/{$g.img_original}" width="100" height='80' alt="详情页图片"/>
	                                <a href="javascript:;" onclick="delGalleryImage(this,{$g.goods_gallery_id});">X</a>
	                            </li>
		                        </list>
		                    </ul>
			                </div>
	        				<ul id="imageList" style="clear: both">
        					<li>
    						<a href="javascript:addImage()">[+]</a>
    						<input type="file" name='gallery_img[]' class='w100'>
        					</li>
	        				</ul>
	        			</td>
	        		</tr>
        		</table>       		
        	</div>
<!-- 商品属性	 -->
		<div id='attribute'>
        	<table class='table1'>
        		<tr>
        			<th class='w100'>商品类型</th>
        			<td>
        				<select name="goods_type" id="goods_type" onchange="getAttr();">
                            <option value="">==选择类型==</option>
        					<list from='$goods_type' name='$gt'>
							<option value="{$gt.cat_id}">{$gt.cat_name}</option>
        					</list>
        				</select>
        			</td>
        		</tr>
            <tr>
              <th>属性</th>
              <td>
                 <div id="attr">

                </div>
              </td>
            </tr>
        	</table>
        </div>
    </div>
</div>
<input type="submit" value='编辑' class='hd-success'>
</form>
</body>
</html>